package tech.wangtong.util;

import java.util.List;

//适用于任何情况的分页
//PageHelper<A>表示创建对象时可以自定义泛型
//new PageHelper<User>();   A=User类型
public class PageHelper<A> {
    private Integer pageNum;//当前页数--前端
    private Integer pageSize;//每页条数--后端默认，前端提供
    private Integer totalCount;//总条数--(数据库提供)
    private Integer totalPage;//总页数--根据总条数和每页条数计算
    private List<A> list;//每页集合数据(数据库提供)

    public Integer getPageNum() {
        return pageNum;
    }


    public void setPageNum(Integer pageNum) {
        this.pageNum = pageNum;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(Integer totalCount) {
        this.totalCount = totalCount;
    }

    public Integer getTotalPage() {
        totalPage=(int)Math.ceil(totalCount*1.0/pageSize);
        return totalPage;
    }

    public void setTotalPage(Integer totalPage) {
        this.totalPage = totalPage;
    }

    public List<A> getList() {
        return list;
    }

    public void setList(List<A> list) {
        this.list = list;
    }
}
